﻿using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text;
using FDStudio.Core.Config.SE;
using FDStudio.Core.Entities;

namespace FDStudio.Core.Search
{
    /*
     CreatedOn: 2018-03-13
     CreatedBy: Jackie Lee(天宇遊龍)
     */
    /// <summary>
    /// 搜索
    /// </summary>
    public abstract class SearchEngine : ISearchEngine
    {
        /// <summary>
        /// 搜索名称
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// 搜索配置
        /// </summary>
        protected ISearchEngineConfig _config;

        public SearchEngine(ISearchEngineConfig config)
        {
            _config = config;
        }

        /// <summary>
        /// 创建索引
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="searchEngineConfig">配置</param>
        /// <param name="data"></param>
        /// <returns></returns>
        public abstract IApiResult BuildIndex<T>(IList<T> data) where T : IEntity;

        /// <summary>
        /// 搜索逻辑
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="condition"></param>
        /// <returns></returns>
        //public abstract IList<T> Search<T>(string condition) where T : IEntity;

        public abstract IList<T> Search<T>(string condition, int pageSize, int pageIndex, out int totalRecord) where T : IEntity;

        public abstract IList<T> Search<T>(string keyword, IList<FieldWeight> fieldWeights, IList<string> wildcardFields, int pageSize, int pageIndex, out int totalRecord) where T : IEntity;
    }
}
